<include file="../header" />
<body class="J_scroll_fixed">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=FO5BZ-2AC2G-ACAQV-I5BD3-YX65K-76BUB"></script>
    <script src="http://open.map.qq.com/apifiles/v1.0/app.js?v=1.0.131203.1" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {

            var vipId = "{$vip.vip_id}";
        
            $('input.checkCode').click(function() {

                var code = $('input[name=code]').val();

                $.ajax({
                    type: "post",
                    url: "{:U('vip/checkCode')}",
                    data: {code: code,vipId:vipId},
                    dataType: "json",
                    success: function(data) {

                        if (data['errCode'] === 500) {
                            layer.msg('该凭证号无效已过期!');
                            $('#checkCodeDiv').attr('style','display:none;');
                            $('input[name=cardType]').val("");
                            $('input[name=shopName]').val("");
                            $('input[name=termNumber]').val("");
                            $('input[name=price]').val("");
                        } else {
                            layer.msg('该凭证号有效!');
                            $('#checkCodeDiv').show();
                            $('input[name=cardType]').val(data['cardType']);
                            $('input[name=shopName]').val(data['shopName']);
                            $('input[name=termNumber]').val(data['termNumber']);
                            $('input[name=price]').val(data['price']);
                            $('input[name=finger]').val(data['finger']);
                            $('input[name=cardNumber]').val(data['cardNumber']);
                        }
                    },
                    error: function() {
                        layer.msg('请求出错！！');
                    }
                });
            });
            $('button.onlineopen').click(function() {
                var code = $('input[name=code]').val();
                var finger = $('input[name=finger]').val();
                var cardNumber = $('input[name=cardNumber]').val();
                if (code == '' || code == null) {
                    layer.msg('code不能为空!');
                    return false;
                } 
                if (finger == '' || finger == null) {
                    layer.msg('指纹不能为空!');
                    return false;
                }
                if (cardNumber == '' || cardNumber == null) {
                    layer.msg('卡号不能为空!');
                    return false;
                }else {
                    $("#onlineform").submit();
                }
            });

        });
    </script>
    <div class="wrap jj">
        <div class="common-form">
            <form id="onlineform" method="post" class="form-horizontal J_ajaxForm" action="{:U('vip/onlineOpenPost')}">
                <input type="hidden" name='id' value='{$vip.vip_id}'/>
                <fieldset>
                    <div class="control-group">
                        <label class="control-label">凭证号：</label>
                        <div class="controls">
                            <input type="text" class="input" name="code" value="">
                            <input type="button" class="checkCode btn" id="{$vip.vip_id}" value="验证" />
                        </div>                                               
                    </div>
                    <div  id="checkCodeDiv" style="display:none;">
                        <div class="control-group">
                            <label class="control-label">店铺:</label>
                            <div class="controls">
                                    <input type="text" class="input" name="shopName" value=""  readOnly=＂true＂>    
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">会员卡类型：</label>
                            <div class="controls">
                                    <input type="text" class="input" name="cardType" value=""  readOnly=＂true＂>    
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">时长：</label>
                            <div class="controls">
                                <input type="text" class="input" name="termNumber" value="0"  readOnly=＂true＂>    
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">总额：</label>
                            <div class="controls">
                                <input type="text" class="input" name="price" value="0"  readOnly=＂true＂>    
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">指纹号：</label>
                            <div class="controls">
                                <input type="text" class="input" name="finger" value="">    
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">卡号：</label>
                            <div class="controls">
                                <input type="text" class="input" name="cardNumber" value="">    
                            </div>
                        </div>
                    </div>
                </fieldset>
                <div class="form-actions">
                    <button  class="onlineopen btn" id="send">开通</button>
                </div>
            </form>
        </div>
    </div>    
    <script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>